package com.ethan.pluginone;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import com.ethan.pluginlib.PluginInterface;
import com.ethan.pluginlib.ProxyActivityInterface;

public
/**
 * @Description:
 * @Author ethan
 * @CreateDate: 2021/12/13 14:27
 * @UpdateDate: 2021/12/13 14:27
 * @Version 1.0
 */
class BaseActivity extends AppCompatActivity implements PluginInterface {

    protected Activity mProxyActivity;

    @Override
    public void attach(Activity proxyActivity) {
        this.mProxyActivity = proxyActivity;
    }

    @SuppressLint("MissingSuperCall")
    @Override
    public void onCreate(Bundle saveInstanceState) {

    }

    @SuppressLint("MissingSuperCall")
    @Override
    public void onStart() {

    }

    @SuppressLint("MissingSuperCall")
    @Override
    public void onResume() {

    }

    @SuppressLint("MissingSuperCall")
    @Override
    public void onPause() {

    }

    @SuppressLint("MissingSuperCall")
    @Override
    public void onStop() {

    }

    @SuppressLint("MissingSuperCall")
    @Override
    public void onDestroy() {

    }

    @Override
    public void onSaveIntanceState(Bundle outState) {

    }

    @Override
    public void setContentView(View view) {
        if (null != mProxyActivity) {
            mProxyActivity.setContentView(view);
        } else
            super.setContentView(view);
    }

    @Override
    public void setContentView(int layoutResID) {
        if (null != mProxyActivity) {
            mProxyActivity.setContentView(layoutResID);
        } else
            super.setContentView(layoutResID);
    }

    @Override
    public void startActivity(Intent intent) {
        if (mProxyActivity != null) {
            intent.putExtra("ClassName", intent.getComponent().getClassName());
            mProxyActivity.startActivity(intent);
        }else{
            super.startActivity(intent);
        }
    }
    @Override
    public <T extends View> T findViewById(int id) {
        return mProxyActivity.findViewById(id);
    }

    @Override
    public Intent getIntent() {
        return mProxyActivity.getIntent();
    }

    @Override
    public ClassLoader getClassLoader() {
        return mProxyActivity.getClassLoader();
    }


}
